//
//  User.m
//  Hive
//
//  Created by 惠俊贝 on 15/8/19.
//  Copyright (c) 2015年 ZM. All rights reserved.
//

#import "UserAccount.h"
#import "DDXML.h"

@implementation UserAccount

- (id)initWithCoder:(NSCoder *)aDecoder {
 
    self = [super init];
    if ([aDecoder containsValueForKey:@"UserName"]) {
        _UserName = [aDecoder decodeObjectForKey:@"UserName"];
    }
    if ([aDecoder containsValueForKey:@"Password"]) {
        _Password = [aDecoder decodeObjectForKey:@"Password"];
    }
    return self;
    
}

- (void)encodeWithCoder:(NSCoder *)aCoder {
    [aCoder encodeObject:_UserName forKey:@"UserName"];
    [aCoder encodeObject:_Password forKey:@"Password"];
}

- (NSDictionary *)encodeToDictionary {
    return @{@"UserName":_UserName,
             @"Password":_Password};
}
- (NSString *)encodeToXMLString {
    NSString *rs = @"";
    if (_UserName) {
        DDXMLElement *paranode=[DDXMLElement elementWithName:@"UserName" stringValue:_UserName];
        rs = [rs stringByAppendingString:[paranode XMLString]];
    }
    if (_Password) {
        DDXMLElement *paranode=[DDXMLElement elementWithName:@"Password" stringValue:_Password];
        rs = [rs stringByAppendingString:[paranode XMLString]];
    }
    return rs;
}
@end
